
package com.jf.cloud.api.product.feign;

import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.product.vo.SkuAddrVO;
import com.jf.cloud.common.product.vo.SkuVO;
import com.jf.cloud.common.product.vo.app.SkuAppVO;
import com.jf.cloud.common.product.vo.search.SpuAdminVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author zz
 * @date 2020/11/12
 */
@FeignClient(value = "jfcloud-product",contextId = "sku")
public interface SkuFeignClient {

    /**
     * 通过skuId获取sku信息
     * @param skuId skuId
     * @return sku信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/sku/getById")
    ServerResponseEntity<SkuVO> getById(@RequestParam("skuId") Long skuId);

    /**
     * 通过spuId获取sku信息
     * @param spuId spuId
     * @return sku信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/sku/listBySpuId")
    ServerResponseEntity<List<SkuAppVO>> listBySpuId(@RequestParam("spuId") Long spuId);

    /**
     * 通过spuIds获取sku信息
     * @param spuIds spuIds
     * @return sku信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/sku/listBySpuIds")
    ServerResponseEntity<List<SkuVO>> listBySpuIds(@RequestParam("spuIds") List<Long> spuIds);

    /**
     * 获取供应商商品信息（包括供应商库存和商家库存）
     * @param spuIds
     * @param shopId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/sku/listSupplierByIds")
    ServerResponseEntity<List<SkuVO>> listSupplierBySpuIds(@RequestParam("skuIds") List<Long> spuIds, @RequestParam("shopId") Long shopId);

    /**
     * 根据skuId列表获取商品列表
     * @param skuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/listSpuDetailByIds")
    ServerResponseEntity<List<SkuAddrVO>> listSpuDetailByIds(@RequestBody List<Long> skuIds);


    /**
     * 根据skuId列表获取售价最低的商品的售价
     * @param skuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/getMinPriceFeeByIds")
    ServerResponseEntity<Long> getMinPriceFeeByIds(@RequestBody List<Long> skuIds);

    /**
     * 供应商SKU变化同步供应商发货的代销商品
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/synCommissionSku")
    ServerResponseEntity<Void> synCommissionSku(@RequestParam("supplierSpuId") Long supplierSpuId);

    /**
     * 供应商品市场价变更后同步代销商品市场价
     * @param skuId
     * @param price
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/synMarketPrice")
    ServerResponseEntity<Void> synMarketPrice(@RequestParam("skuId") Long skuId,@RequestParam("price") Long price);

    /**
     * 获取代销商品sku信息以及供应商品SKU库存
     * @param supplierSpuId
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/listConsignmentSku")
    ServerResponseEntity<Map<Long,Integer>> listConsignmentSku(@RequestParam("spuId") Long spuId,@RequestParam("supplierSpuId") Long supplierSpuId);

    /**
     * 通过skuIds获取sku信息
     * @param skuIds skuIds
     * @return sku信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/sku/getByIds")
    ServerResponseEntity<List<SkuVO>> getByIds(@RequestBody List<Long> skuIds);

    /**
     * 获取商品sku保存到商品列表
     * @param spuAdminVOS
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/sku/setSpuSku")
    ServerResponseEntity<List<SpuAdminVO>> setSpuSku(@RequestBody List<SpuAdminVO> spuAdminVOS);

}
